package lab.bmp;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

/**
 *
 * @author Smike
 */
public class LookupHelper {
    
    InitialContext ic;

    public LookupHelper() throws NamingException {
        ic = new InitialContext();
    }
    
    public <T> T lookup(Class<T> clazz) throws NamingException {
        return (T) PortableRemoteObject.narrow(ic.lookup(clazz.getName()), clazz);
    }
    
    public <T> T lookup(String path, Class<T> clazz) throws NamingException {
        return (T) PortableRemoteObject.narrow(ic.lookup(path), clazz);
    }
    
}
